import java.io.IOException;
import java.net.URL;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.xml.sax.SAXException;





public class XMLParser {
	private String key;
	private String baseURL;
	DocumentBuilder builder;

	public XMLParser (String key, String baseURL) throws ParserConfigurationException{
		this.key = "?key="+key;
		this.baseURL=baseURL;
		builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
	}
	
	public String getTime() throws SAXException, IOException{
		URL url = new URL(baseURL+"getTime"+key);
		Document doc = builder.parse(url.openStream());
		return null;
	}
	public String[] getRouteVehicles(String shortName) throws SAXException, IOException{
		URL url = new URL(baseURL+"getVehicles"+key+"&vid="+shortName);
		Document doc = builder.parse(url.openStream());
		return null;
	}
	public String[]  getRouteDirections(String shortName) throws SAXException, IOException{
		URL url = new URL(baseURL+"getDirections"+key+"&rt="+shortName);
		Document doc = builder.parse(url.openStream());
		return null;
	}
	public String[] getRouteStops(String shortName, String direction) throws SAXException, IOException{
		URL url = new URL(baseURL+"getStops"+key+"&rt="+shortName+"&dir="+direction);
		Document doc = builder.parse(url.openStream());
		return null;
	}
	public String[] getRoutePoints(String shortName) throws SAXException, IOException{
		URL url = new URL(baseURL+"getStops"+key+"&rt="+shortName);
		Document doc = builder.parse(url.openStream());
		return null;
	}
	public String[] getStopPredictions(String stopID) throws SAXException, IOException{
		URL url = new URL(baseURL+"getStops"+key+"&stpid="+stopID);
		Document doc = builder.parse(url.openStream());
		return null;
	}
	public String[] getRoutePredictions(String route) throws SAXException, IOException{
		URL url = new URL(baseURL+"getStops"+key+"&rt="+route);
		Document doc = builder.parse(url.openStream());
		return null;
	}
	public String[] getStopAndRoutePredictions(String stopID, String route) throws SAXException, IOException{
		URL url = new URL(baseURL+"getStops"+key+"&stpid="+stopID+"&rt="+route);
		Document doc = builder.parse(url.openStream());
		return null;
	}
}
